from typing import Optional
from com.linkstec.dao.base.base_dao import BaseDao
from com.linkstec.models.company_info import CompanyInfo

class CompanyInfoDao(BaseDao):
    def find_all(self) -> list[CompanyInfo]:
        query = "SELECT secc_id, secc_name FROM securities_company_info"
        return [CompanyInfo(**row) for row in self.execute_query(query)]

    def find_by_name(self, secc_name: str) -> Optional[CompanyInfo]:
        query = "SELECT secc_id, secc_name FROM securities_company_info WHERE secc_name = %s"
        result = self.execute_query(query, (secc_name,))
        return CompanyInfo(**result[0]) if result else None